import {createRouter, createWebHistory} from "vue-router";
import Layout from "@/components/layout";

const routes = [
    {
        path: "/",
        component: Layout,
        redirect: "/dashboard",
        children: [
            {
                path: "dashboard",
                name: "Dashboard",
                component: () => import("@/views/dashboard"),
                meta: {title: "仪表盘"}
            }
        ]
    },
    {
        path: "/article",
        component: Layout,
        redirect: "/article/list",
        meta: {title: "文章管理"},
        children: [
            {
                path: "list",
                name: "ArticleList",
                component: () => import("@/views/article"),
                meta: {title: "文章列表"}
            },
            {
                path: "create",
                name: "ArticleCreate",
                component: () => import("@/views/article/create"),
                meta: {title: "创建文章"}
            },
            {
                path: "edit/:id",
                name: "ArticleEdit",
                component: () => import("@/views/article/edit"),
                meta: {title: "编辑文章"},
                hidden: true
            },
            {
                path: "category",
                name: "Category",
                component: () => import("@/views/article/category"),
                meta: {title: "分类管理"}
            },
            {
                path: "tab",
                name: "Tab",
                component: () => import("@/views/article/tag"),
                meta: {title: "标签管理"}
            }
        ]
    },
    {
        path: "/user",
        component: Layout,
        redirect: "/user/list",
        children: [
            {
                path: "list",
                name: "UserList",
                component: () => import("@/views/user"),
                meta: {title: "用户管理"}
            }
        ]
    },
    {
        path: "/settings",
        component: Layout,
        children: [
            {
                path: "",
                name: "Settings",
                component: () => import("@/views/dashboard"),
                meta: {title: "系统设置"}
            }
        ]
    },
    // 404页面
    {
        path: "/:pathMatch(.*)*",
        redirect: "/"
    }
];

const router = createRouter({
    routes,
    history: createWebHistory(),
});

export default router;
